package com.andyyan.ai.chatbot.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApiResult <T> implements Serializable {
    /**
     * 0 代表成功，非0代表错误码
     */
    private int code;
    private String msg;
    private T data;

    public static <T> ApiResult<T> success(T data) {
        return new ApiResult<>(0, "Success", data);
    }

    public static <T> ApiResult<T> fail(int code, String msg, T data) {
        return new ApiResult<>(code, msg, data);
    }


}
